<!-- 供应商 -->
<template>
    <div>
        <el-table
            ref="customerTable"
            :data="tableData"
            stripe
            style="width: 100%"
            @row-dblclick="getSelectVal"
        >
            <el-table-column type="selection" width="55" align="center">
            </el-table-column>
            <el-table-column
                type="index"
                align="center"
                label="序号"
                width="55"
            ></el-table-column>
            <el-table-column prop="supplierCode" label="供应商编码">
                <template slot-scope="scope">{{
                    scope.row.supplierCode || "--"
                }}</template>
            </el-table-column>
            <el-table-column prop="supplierName" label="供应商名称">
                <template slot-scope="scope">{{
                    scope.row.supplierName || "--"
                }}</template>
            </el-table-column>
            <el-table-column prop="supplierGroup" label="供应商分组">
                <template slot-scope="scope">{{
                    scope.row.supplierGroup || "--"
                }}</template>
            </el-table-column>

            <el-table-column prop="paymentTerms" label="付款条件">
                <template slot-scope="scope">{{
                    scope.row.paymentTerms || "--"
                }}</template>
            </el-table-column>
            <el-table-column prop="contactsTel" label="联系人手机">
                <template slot-scope="scope">{{
                    scope.row.contactsTel || "--"
                }}</template>
            </el-table-column>
            <el-table-column prop="supplierLevel" label="供应商等级">
                <template slot-scope="scope">
                    <el-tag
                        v-if="scope.row.supplierLevel === '0'"
                        type="success"
                        >A</el-tag
                    >
                    <el-tag
                        v-else-if="scope.row.supplierLevel === '1'"
                        type="info"
                        >B</el-tag
                    >
                    <el-tag
                        v-else-if="scope.row.supplierLevel === '2'"
                        type="warning"
                        >C</el-tag
                    >
                    <el-tag
                        v-else-if="scope.row.supplierLevel === '3'"
                        type="danger"
                        >D</el-tag
                    >
                    <span v-else></span>
                </template>
            </el-table-column>
            <el-table-column prop="classification" label="供应商分类">
                <template slot-scope="scope">
                    <el-tag
                        v-if="scope.row.classification === '0'"
                        type="success"
                        >A</el-tag
                    >
                    <el-tag
                        v-else-if="scope.row.classification === '1'"
                        type="info"
                        >B</el-tag
                    >
                    <el-tag
                        v-else-if="scope.row.classification === '2'"
                        type="warning"
                        >C</el-tag
                    >
                    <el-tag
                        v-else-if="scope.row.classification === '3'"
                        type="danger"
                        >D</el-tag
                    >
                    <span v-else></span>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
            class="pagination mt10"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="page"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
        >
        </el-pagination>
    </div>
</template>

<script>
import { getSupplierData } from "@/api/base/data";
export default {
    data() {
        return {
            tableData: [],
            page: 1, //当前页
            limit: 10, //每页条数
            total: 0,
        };
    },
    methods: {
        //分页器size
        handleSizeChange(val) {
            this.limit = val;
            this.getDataList();
        },
        //分页器当前页
        handleCurrentChange(val) {
            this.page = val;
            this.getDataList();
        },
        getSelectVal(val) {
            this.$emit("row-dblclick", val);
        },
        getDataList() {
            let params = {
                page: this.page,
                limit: this.limit,
            };
            getSupplierData(params).then((res) => {
                this.tableData = res.rows;
                this.total = res.total;
            });
        },
    },
    mounted() {
        this.getDataList();
    },
};
</script>

<style></style>
